﻿using System;
using System.Collections;
using System.Collections.Generic;
using Me.Prettyprint.Cassandra.Connection;
using Me.Prettyprint.Cassandra.Service;
using Me.Prettyprint.Cassandra.Serializers;
using Me.Prettyprint.Cassandra.Utils;
using Me.Prettyprint.Hector.Api;
using Me.Prettyprint.Hector.Api.Beans;
using Me.Prettyprint.Hector.Api.Query;
using Org.Apache.Cassandra.Thrift;
using Thrift;

namespace Me.Prettyprint.Cassandra.Model
{
    public class OrderedRowsImpl<K, N, V> : RowsImpl<K, N, V>, OrderedRows<K, N, V>
    {
        public OrderedRowsImpl(Dictionary<K, List<Column>> thriftRet, Serializer<N> nameSerializer,
            Serializer<V> valueSerializer)
            : base(thriftRet, nameSerializer, valueSerializer)
        {
            List = new List<Row<K, N, V>>(Rows.Values);
        }
        protected OrderedRowsImpl() : base()
        {
            List = new List<Row<K, N, V>>();
        }

        public List<Row<K, N, V>> List
        {
            get;
            protected set;
        }
        public Row<K, N, V> PeekLast()
        {
            return List != null && List.Count > 0 ? List[List.Count-1] : null;
        }
    }
}
